<%@ page contentType="text/html;charset=utf-8" %>
<%@ page import="ut.data.User" %>
<%
	User user = (User)session.getAttribute("user");
	if(user == null){
		response.sendRedirect("/");
		return;
	}
%>
<!DOCTYPE html>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title>UT終極一翻！ | 儲值</title>
	<link rel="stylesheet" type="text/css" href="/style.css" media="all" />
	<script type="text/javascript" src="/js/Utility.js"></script>
	<script type="text/javascript" src="/js/Message.js"></script>
	<script type="text/javascript" src="/js/Ajax.js"></script>
	<script type="text/javascript" src="/js/Button.js"></script>
	<script type="text/javascript" src="/js/Account.js"></script>
	<script type="text/javascript" src="/script.js"></script>
	<script type="text/javascript" src="https://www.paypalobjects.com/js/external/dg.js"></script>
</head>
<body onload="init();">
<%@ include file="/include/banner.jsp" %>
	<div class="content">
		<div class="title">儲值至本站</div>
		<form class="block-center" method="post" action="/exe/member/paypal/SetPayment">
			請輸入欲儲值的金額：NTD <input type="text" style="width:80px;text-align:center" name="money" /> 元<br/>
			<span class="mark-red comment">單次儲值最低 NTD 200 元，最高 NTD 50000 元。</span><br/>
			<span class="mark-red comment">本站金流全權委託 <a target="_blank" href="http://www.paypal.com/">PayPal</a> 處理，因此不會取得您在付款過程中填寫的任何資料，請放心使用。</span><br/>
			<span class="mark-red comment">付款成功後將立即入帳，稍後您隨時可查閱交易紀錄來進行確認。</span><br/>
			<br/>
			<input type="checkbox" name="agree" onclick="if(this.checked){document.getElementById('paypal').disabled=false;}else{document.getElementById('paypal').disabled=true;}" /> 我已了解並同意以上括號中的注意事項。<br/>
			<input class="button" style="margin-top:30px" type="submit" id="paypal" 
				value="使用【PayPal】或【信用卡/VISA金融卡】付款"
				onmousedown="this.style.borderStyle='inset'"
				onmouseup="this.style.borderStyle='outset'"
				onmouseout="this.style.borderStyle='outset'" disabled />
		</form>
		<div style="text-align:center">
			點擊按鈕後，請參考以下畫面說明，選擇您的付款方式：<br/><br/>
			<img src="/image/paypal.png" />
		</div>
		<script type="text/javascript">
			var paypal = new PAYPAL.apps.DGFlow({trigger:"paypal", expType:"mini"});
			function doPayment(money, token, payerId){
				Message.show("msg-deposit-processing", 400, "系統處理中", Ajax.loadingImg);
				Ajax.sendRequest(
					"post", "/exe/member/paypal/DoPayment", 
					"money=" + money + "&token=" + encodeURIComponent(token) + "&payer_id=" + payerId, true,
					function(req){
						Message.hide("msg-deposit-processing");
						var result = req.getResponseHeader("result");
						switch(result){
							case "1":
								// 付款成功
								Message.show(
									"msg-deposit-result", 400, "處理成功", "恭喜！您已儲值成功。", 
									new Message.Button("確定", function(){document.location.reload(true);})
								);
								return;
							default:
								// 付款失敗
								Message.show(
									"msg-deposit-result", 400, "處理失敗", "很抱歉，您儲值失敗。請稍後重試或聯絡客服。", 
									new Message.Button("確定", function(){document.location.reload(true);})
								);
								return;
						}
					}
				);
			}
		</script>
<%@ include file="/include/foot.jsp" %>
	</div>
</body>
</html>